package cn.yangliu.springbatch.job;

import cn.yangliu.springbatch.entity.Role;
import cn.yangliu.springbatch.repository.RoleRepository;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.annotation.BeforeStep;
import org.springframework.batch.item.ItemWriter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * the type of springbatch
 *
 * <p>
 * .
 *
 * @author 杨柳
 * @date 2021-07-12
 */
@Component
public class RoleWriter implements ItemWriter<Role> {



    @Autowired
    private RoleRepository roleRepository;

    @Override
    public void write(List<? extends Role> list) throws Exception {

    }

    @BeforeStep
    public void beforeStep(StepExecution stepExecution) {
        Object userList = stepExecution.getJobExecution().getExecutionContext().get("userList");
        System.out.println("role writer : " + userList);
    }
}
